#!/bin/bash

cd $(dirname $0)/..
: ${ARTIFACTS:=$(pwd)/dist/artifacts}

./scripts/ci 2>&1 | tee build.log
mv build.log dist/build_${ARCH}.log

echo
echo "to publish release to github, run dist/publish.sh"

echo "#!/bin/sh"> dist/publish.sh
if [ "${ARCH}" == "amd64" ]; then
    echo "github-release release --user burmilla --repo os-initrd-base --tag "${RELEASE_VERSION}" --pre-release" >> dist/publish.sh
    echo "echo Waiting 30 seconds after release creation to make sure that GitHub is ready for uploads" >> dist/publish.sh
    echo "sleep 30s" >> dist/publish.sh
fi
echo "github-release upload  --user burmilla --repo os-initrd-base --tag "${RELEASE_VERSION}" --file ./dist/artifacts/os-initrd-base-${ARCH}.tar.gz --name os-initrd-base-${ARCH}.tar.gz" >> dist/publish.sh

chmod 755 dist/publish.sh
